using Microsoft.AspNetCore.Razor.TagHelpers;

namespace ReaWTM.LayuiHelper
{
	[HtmlTargetElement("wt:closebutton", TagStructure = TagStructure.WithoutEndTag)]
	public class CloseButtonTagHelper : BaseButtonTag
	{
		public bool IsRefreshGrid { get; set; }
		public CloseButtonTagHelper()
		{
			Theme = ButtonThemeEnum.Primary;
		}
		string GetIsRefreshGridString()
		{
			if (IsRefreshGrid)
			{
				return "ff.RefreshGrid('LAY_app_body',0);";
			}
			else
			{
				return "";
			}
		}
		public override void Process(TagHelperContext context, TagHelperOutput output)
		{
			if (string.IsNullOrEmpty(Text))
			{
				Text = THProgram._localizer["Sys.Close"];
			}
			Click = $"ff.CloseDialog();{GetIsRefreshGridString()}";

			base.Process(context, output);
		}
	}
}
